package com.jhg.drgclinicalpathway.controller.DATA;

import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
public class Jbdz {

    public static Map<String, String> YBBM = (Map)getLines("jbdz").collect(Collectors.toMap((x) -> {
        return x.substring(0, x.indexOf(" "));
    }, (x) -> {
        return x.substring(x.indexOf(" ") + 1);
    }));

    public static Map<String, String> SSBM = (Map)getLines("ssdz").collect(Collectors.toMap((x) -> {
        return x.substring(0, x.indexOf(" "));
    }, (x) -> {
        return x.substring(x.indexOf(" ") + 1);
    }));
    private static Stream<String> getLines(String dataFile) {
        BufferedReader br = null;
        try
        {
            //String ras = "/" + Jbdz.class.getPackage().getName().replace(".", "/") + "/" + dataFile + ".dat";
            InputStream inputStream = Jbdz.class.getClassLoader().getResourceAsStream(dataFile+".dat");
            br = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
        } catch (Exception ex) {
            System.out.println("初始化数据文件失败！");
            ex.printStackTrace();
        }
        return br.lines();
    }
}
